Import the library.
In [1]:
import polypy
Create variables $x$, $y$, $z$.
In [2]:
x = polypy.Variable('x')
In [3]:
[y, z] = [polypy.Variable(s) for s in ['y', 'z']]
Variable Ordering:
In [4]:
order = polypy.variable_order
In [5]:
order.push(z)
In [6]:
order.push(y)
In [7]:
order
Out[7]:
In [8]:
order.pop()
In [9]:
order.push(x)
In [10]:
order
Out[10]:
Creating Polynomials:
In [11]:
f = (x**2 - 2*x + 1)*(x**2 - 2)
In [12]:
g = z*(x**2 - y**2)
Variable order & Polynomials
In [13]:
order.set([x, y, z])
In [14]:
print g
In [15]:
order.set([z, y])
In [16]:
print g
Basic operations
In [17]:
g.var()
Out[17]:
In [18]:
g.degree()
Out[18]:
In [19]:
g.coefficients()
Out[19]:
In [20]:
g.derivative()
Out[20]:
In [21]:
f.factor_square_free()
Out[21]:
In [22]:
g.factor_square_free()
Out[22]:
In [23]:
f
Out[23]:
In [24]:
f.reductum()
Out[24]:
Root isolation:
In [25]:
m = polypy.Assignment()
In [26]:
r = f.roots_isolate(m)
In [27]:
r
Out[27]:
In [28]:
print r[0]
In [29]:
print r[1]
In [30]:
print r[2]
Values can be integers, rationals, or algebraic numbers.
In [31]:
r[0].to_double()
Out[31]:
In [32]:
r[0] > r[1]
Out[32]:
In [33]:
r[0].get_value_between(r[1])
Out[33]:
In [34]:
m.set_value(x, 0)
In [35]:
f.sgn(m)
Out[35]:
In [36]:
m.set_value(x, r[0])
In [37]:
f.sgn(m)
Out[37]:
In [ ]: